/**
 * Created by zhuhuijun on 2017-7-26 18:18:30
 */
app.controller('FileInfoListCtrl', FileInfoListCtrl);
FileInfoListCtrl.$inject = ['dbprofileService', 'ngTableService', 'toaster', 'commonService'];
function FileInfoListCtrl(dbprofileService, ngTableService, toaster, commonService) {
    var vm = this;
    //all function here
    //-----------------
    vm.init = init;
    vm.add = add;
    vm.submit = submit;
    vm.loadFiles = loadFiles;
    vm.processFile = processFile;
    //all view object here
    //------------------
    //all function call here
    //-----------------------
    function init() {
        commonService.postSend("fileInfo/fileInfoList.do", {status:"N"}).then(function (response) {
            vm.tableParam = ngTableService.init(response.data)
        })
    }

    function loadFiles() {
        layer.prompt({title: '请输入文件读取路径', formType: 2, value: "E:/Test/scanfile"}, function (pass, index) {
            layer.close(index);
            commonService.postSend("fileInfo/loadFile.do", {path: pass,areNum:"7"}).then(function (response) {
                toaster.pop("success", "提示信息", "文件读取完毕!");
                init();
            });
        });
    }

    function processFile() {
        commonService.postSend("fileInfo/processFile.do", {
            storagePath: "E:/Test/processedfile"
        }).then(function (response) {
            toaster.pop("success", "提示信息", "文件处理完毕!");
        })
    }

    function submit() {
    }

    function add() {
    }

    function layerOpen(title, contentId) {
        layer.open({
            type: 1
            , area: ['750px', '500px']
            , title: title
            , shade: 0.6
            , maxmin: true
            , anim: 1
            , content: $("#" + contentId)
        });
    }
}
